<template>
    <div>
        <!-- 订单编号 <el-input v-model="formData.name" style="width: 200px;" placeholder="Please input" />
        手机号 <el-input v-model="formData.administrative" style="width: 200px;" placeholder="Please input" />
        <el-button type="primary" @click="submit">查询</el-button> -->

        <ElTable :data="state.list">
            <el-table-column type="selection" width="55" />
            <ElTableColumn prop="id" label="订单编号"></ElTableColumn>
            <ElTableColumn prop="name" label="患者姓名"></ElTableColumn>
            <ElTableColumn prop="department" label="挂号科室"></ElTableColumn>
            <ElTableColumn prop="further" label="是否为复诊"></ElTableColumn>
            <ElTableColumn prop="48report" label="是否自我申报48小时核算"></ElTableColumn>

            <el-table-column label="操作">
                <template #default="{ row }">
                    <el-popconfirm title="删除了？" @confirm="deleteUser(row.id)">
                        <template #reference>
                            <el-icon color="#409EFC" class="no-inherit">
                                <Delete />
                            </el-icon>
                        </template>
                    </el-popconfirm>
                </template>
            </el-table-column>

        </ElTable>


        <el-pagination v-model:page-size="pageInfo.pageSize" v-model:current-page="pageInfo.currentPage"
            layout="prev, pager, next, sizes" :page-sizes="[5, 8, 10, 15]" :total="state.total" />


    </div>
</template>

<script setup lang="ts">
import { registerlist, registerdel } from '../../api/register.api'
import { reactive, watchEffect, ref } from 'vue';
import { IRegister } from '../../type/doctor.type'
const BASE_URL = import.meta.env.VITE_IMG_URL
const pageInfo = reactive({
    currentPage: 1,
    pageSize: 5,
})



type State = {
    list: IRegister[],
    total: number
}

const state = reactive<State>({
    list: [],
    total: 0
})

const getUsers = () => {
    registerlist(pageInfo.currentPage, pageInfo.pageSize).then(res => {
        console.log(res.data.data);
        if (res.data.data.length > 0) {
            state.total = res.data.total!
            state.list = res.data.data
        }
    })
}

// 用户查询接口 
watchEffect(getUsers)

// 删除
const deleteUser = async (id: number) => {
    console.log(id);
    await registerdel(id)
    getUsers()
}


</script>

<style scoped>
img {
    width: 50px;
    height: 50px;
}
</style>